<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;
use App\Models\GoodsBrand;
use Illuminate\Http\Request;

class GoodsBrandController extends Controller
{
    public function data(Request $request)
    {
        $res = GoodsBrand::query();
        if($request->get('category_id')){
            $res = $res->where("category_id" , $request->get('category_id'));
        }
        $res = $res->orderBy('id','desc')
            ->orderBy('sort','desc')
            ->paginate($request->get('limit',30))
            ->toArray();
        $data = [
            'code' => 0,
            'msg'   => '正在请求中...',
            'count' => $res['total'],
            'data'  => $res['data']
        ];
        return response()->json($data);
    }

}
